package com.jvup.gameshow.model.viewModel.impl;

import android.view.View;

import com.jvup.gameshow.R;
import com.jvup.gameshow.controller.LoginGuideController;
import com.jvup.gameshow.dal.service.LoginGuideService;
import com.jvup.gameshow.databinding.ActivityLoginGuideBinding;
import com.jvup.gameshow.model.viewModel.ILoginGuideViewModel;
import com.jvup.common.support.base.BaseViewModel;

public abstract class LoginGuideViewModel extends BaseViewModel<ILoginGuideViewModel> implements ILoginGuideViewModel{

    public LoginGuideService loginGuideService = new LoginGuideService();

    public void initPage(ActivityLoginGuideBinding viewBind, LoginGuideController controller){

        viewBind.appLoginGuidePassword.addEventDrawable(R.drawable.app_compound_icon_pwd_ciphertext,"plaintextBtn");
        viewBind.appLoginGuidePassword.setCompoundEventListener("plaintextBtn",controller::compoundEventPlaintextBtnOnClick);

        viewBind.appLoginGuideRegisterPassword.addEventDrawable(R.drawable.app_compound_icon_pwd_ciphertext,"plaintextBtn");
        viewBind.appLoginGuideRegisterPassword.setCompoundEventListener("plaintextBtn",controller::compoundEventPlaintextBtnOnClick);

        viewBind.appLoginGuideConfirmPassword.addEventDrawable(R.drawable.app_compound_icon_pwd_ciphertext,"plaintextBtn");
        viewBind.appLoginGuideConfirmPassword.setCompoundEventListener("plaintextBtn",controller::compoundEventPlaintextBtnOnClick);

        put("registerBtnTextColor","#ffffff");
        put("registerBtnBackground", R.drawable.app_login_button_pink_bg);
        put("registerBtnEnabled",true);
        toggleTo(true);
    }

    public void register(){
        String phoneNumber = getToValue("phoneNumber");
        String registerPassword = getToValue("registerPassword");

//        loginGuideService.register(phoneNumber, registerPassword, phoneNumber);
    }

    public void toggleTo(boolean isPhoneLogin){
        put("title",isPhoneLogin ? "用户登录" : "用户注册");
        put("phoneLoginPanelVisible", isPhoneLogin ? View.VISIBLE : View.GONE);
        put("registerPanelVisible", isPhoneLogin ? View.GONE : View.VISIBLE);
    }

} 
